package com.deep.deepenterpise.service.unit.impl;

import com.deep.deepenterpise.common.DrGson;
import com.deep.deepenterpise.common.DrTransactionCommon;
import com.deep.deepenterpise.common.code.DrCodeMsg;
import com.deep.deepenterpise.common.enums.*;
import com.deep.deepenterpise.common.lock.DrLockConstants;
import com.deep.deepenterpise.common.lock.DrLockService;
import com.deep.deepenterpise.common.page.DrPageHelper;
import com.deep.deepenterpise.common.result.DrResult;
import com.deep.deepenterpise.common.util.DrDateUtil;
import com.deep.deepenterpise.dao.*;
import com.deep.deepenterpise.model.bo.DrMemberBo;
import com.deep.deepenterpise.model.bo.DrUserInfoBo;
import com.deep.deepenterpise.model.entity.DrDangerHistory;
import com.deep.deepenterpise.model.entity.DrDangerHistoryItem;
import com.deep.deepenterpise.model.entity.DrDangerHistorySlave;
import com.deep.deepenterpise.model.to.unit.*;
import com.deep.deepenterpise.model.vo.DrPageBaseVo;
import com.deep.deepenterpise.model.vo.unit.*;
import com.deep.deepenterpise.service.unit.IDrDangerService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

/**
 * @author xyz
 * @version 1.0
 * @title DrDangerServiceImpl
 * @description
 * @create 2024/6/23 08:43
 */
@Service
@Slf4j
public class DrDangerServiceImpl implements IDrDangerService {
    @Resource
    private DrDangerHistoryMapper drDangerHistoryMapper;
    @Resource
    private DrDangerHistorySlaveMapper drDangerHistorySlaveMapper;
    @Resource
    private DrDangerHistoryItemMapper drDangerHistoryItemMapper;
    @Resource
    private DrSysMemberMapper drMemberMapper;
    @Resource
    private DrCheckItemMapper drCheckItemMapper;
    @Resource
    private DrSysUserMapper drSysUserMapper;
    @Resource
    private DrLockService drLockService;
    @Resource
    private DrTransactionCommon drTransactionCommon;

    /**
     * @return com.deep.deepenterpise.common.result.DrResult
     * @Auth xyz
     * @Desc //TODO 添加隐患历史记录
     * @Time 08:47 2024/6/23
     * @Param [drDangerHistoryTo, drUserUuid]
     */
    @Override
    public DrResult postAddDangerHistory(DrDangerHistoryTo drDangerHistoryTo, String drUserUuid) {
        // 获取用户信息
        DrUserInfoBo drUserInfoBo = drSysUserMapper.findByDrUserUuidAndDrStatus(drUserUuid, DrStateEnum.YES.getDrState());
        if (drUserInfoBo == null) {
            return DrResult.error("检查人不存在或状态异常");
        }

        List<DrUnitCheckItemVo> drCheckItemVos = drCheckItemMapper
                .findByDrCategoryAndDrStatus(DrCategoryEnum.CHECK_BOTTLE.getDrType(), DrStateEnum.YES.getDrState());
        if (CollectionUtils.isEmpty(drCheckItemVos)) {
            return DrResult.error("获取安检项失败");
        }

        DrMemberBo drMemberBo = drMemberMapper.findByDrMemberId(drDangerHistoryTo.getDrMemberId());
        if (drMemberBo == null) {
            return DrResult.error("用户信息不存在");
        }
        drDangerHistoryTo.setDrMemberName(drMemberBo.getDrMemberName());
        drDangerHistoryTo.setDrMemberPhone(drMemberBo.getDrMemberPhone());
        drDangerHistoryTo.setDrMemberAddress(drMemberBo.getDrAddress());

        // 获取订单信息
        String drOrderNum = drDangerHistoryTo.getDrOrderNum();
        return drLockService.executeWithLock(DrLockConstants.CREATE_CHECK_BOTTLE_DANGER_LOCK + drOrderNum,
                6, TimeUnit.SECONDS,
                () -> addBottleDangerHistory(drUserInfoBo, drDangerHistoryTo, drOrderNum, drCheckItemVos));
    }

    /**
     * @return com.deep.deepenterpise.common.result.DrResult
     * @Auth xyz
     * @Desc //TODO 添加隐患历史记录
     * @Time 08:58 2024/6/23
     * @Param [drUserInfoBo, drDangerHistoryTo, drOrderNum]
     */
    private DrResult addBottleDangerHistory(DrUserInfoBo drUserInfoBo, DrDangerHistoryTo drDangerHistoryTo, String drOrderNum,
                                            List<DrUnitCheckItemVo> drCheckItemVos) {
        // 验证订单是否已经存在
        DrDangerHistory dangerHistory = drDangerHistoryMapper.findByDrOrderNum(drOrderNum);
        if (dangerHistory != null) {
            return DrResult.error("隐患记录已存在，请勿重复添加");
        }
        // 获取当前时间
        long drNowTime = DrDateUtil.getCurrentSeconds();
        // 生成隐患单号
        String drDangerNum = DrOrderTypeEnum.DANGER_BOTTLE.getDrCode() + drNowTime;
        return drLockService.executeWithLock(DrLockConstants.CREATE_DANGER_HISTORY_LOCK + drDangerNum,
                6, TimeUnit.SECONDS,
                () -> saveDangerHistory(drUserInfoBo, drDangerHistoryTo, DrCategoryEnum.CHECK_BOTTLE.getDrType(),
                        drOrderNum, drDangerNum, drNowTime, drCheckItemVos));

    }

    /**
     * @return com.deep.deepenterpise.common.result.DrResult
     * @Auth xyz
     * @Desc //TODO 保存隐患历史记录
     * @Time 09:12 2024/6/23
     * @Param [drUserInfoBo, drDangerHistoryTo, drDangerNum, drNowTime]
     */
    @Override
    public DrResult saveDangerHistory(DrUserInfoBo drUserInfoBo, DrDangerHistoryTo drDangerHistoryTo, Integer drType,
                                      String drOrderNum, String drDangerNum, long drNowTime,
                                      List<DrUnitCheckItemVo> drCheckItemVos) {
        // 验证隐患订单是否已经存在
        Long drNum = drDangerHistoryMapper.countByDrOrderNum(drDangerNum);
        if (drNum != null && drNum > 0) {
            return DrResult.error(DrCodeMsg.SYSTEM_BUSY_ERR);
        }

        // 获取是否有隐患
        Integer drIsSafe = drDangerHistoryTo.getDrIsSafe();
        DrContentTo drContent = drDangerHistoryTo.getDrContent();

        // 创建隐患记录，如果是重大隐患，需要设置状态为待检查
        Integer drStatus = drIsSafe == 2 ? DrDangerEnum.NO_START.getDrState() : DrDangerEnum.NO.getDrState();
        DrDangerHistory dangerHistory = new DrDangerHistory(drType, drStatus, drOrderNum, drDangerNum, drNowTime,
                drUserInfoBo, drDangerHistoryTo);

        String drDangerSlaveNum = DrOrderTypeEnum.DANGER_SLAVE.getDrCode() + drNowTime;

        // 创建隐患子记录，如果是重大隐患，需要设置状态为待检查
        Integer drSlaveStatus = drIsSafe == 2 ? DrDangerSlaveEnum.WAIT_CHECK.getDrState()
                : DrDangerSlaveEnum.NO.getDrState();
        List<String> drPhoto = drContent.getDrPhoto();
        DrDangerHistorySlave drDangerHistorySlave = new DrDangerHistorySlave(drDangerNum, drDangerSlaveNum,
                drSlaveStatus, drNowTime, drDangerHistoryTo.getDrRemark(), drPhoto);

        // 创建隐患关联记录
        // 触发的隐患项
        List<DrItemTo> drItem = drContent.getDrItem();
        List<DrDangerHistoryItem> dangerHistoryItems = getDangerHistoryItems(drCheckItemVos, drItem, drDangerSlaveNum,
                drNowTime);

        // 保存记录
        return drTransactionCommon.execute("保存隐患记录", () -> {
            for (DrDangerHistoryItem dangerHistoryItem : dangerHistoryItems) {
                drDangerHistoryItemMapper.insert(dangerHistoryItem);
            }
            drDangerHistorySlaveMapper.insert(drDangerHistorySlave);
            drDangerHistoryMapper.insert(dangerHistory);
        });
    }

    /**
     * @return java.util.List<com.deep.deepenterpise.model.entity.DrDangerHistoryItem>
     * @Auth xyz
     * @Desc //TODO 获取隐患关联记录
     * @Time 09:29 2024/6/24
     * @Param [drCheckItemVos, drContent, drDangerSlaveNum]
     */
    private List<DrDangerHistoryItem> getDangerHistoryItems(List<DrUnitCheckItemVo> drCheckItemVos,
                                                            List<DrItemTo> drItem, String drDangerSlaveNum,
                                                            long drNowTime) {
        Map<Integer, DrItemTo> drItemToMap = Collections.emptyMap();
        if (!CollectionUtils.isEmpty(drItem)) {
            drItemToMap = drItem.stream().collect(Collectors.toMap(DrItemTo::getDrId, drItemTo -> drItemTo));
        }
        List<DrDangerHistoryItem> dangerHistoryItems = new ArrayList<>(drCheckItemVos.size());
        for (DrUnitCheckItemVo drCheckItemVo : drCheckItemVos) {
            Integer drId = drCheckItemVo.getDrId();
            DrItemTo drItemTo = drItemToMap.get(drId);
            if (drItemTo != null) {
                dangerHistoryItems.add(new DrDangerHistoryItem(drDangerSlaveNum, drItemTo, drNowTime));
            } else {
                dangerHistoryItems.add(new DrDangerHistoryItem(drDangerSlaveNum, drCheckItemVo, drNowTime));
            }
        }
        return dangerHistoryItems;
    }

    /**
     * @return com.deep.deepenterpise.common.result.DrResult
     * @Auth xyz
     * @Desc //TODO 获取待检查列表
     * @Time 10:39 2024/6/25
     * @Param [drUserUuid, drDangerPageTo]
     */
    @Override
    public DrResult postDrWaitCheckList(String drUserUuid, DrDangerSlavePageTo drDangerSlavePageTo) {
        Integer drStatus = drDangerSlavePageTo.getDrStatus();
        if (drStatus == 1) {
            drDangerSlavePageTo.setDrSlaveStatus(DrDangerSlaveEnum.WAIT_RECHECK.getDrState());
            drDangerSlavePageTo.setDrDangerStatus(DrDangerEnum.NO_START.getDrState());
        } else {
            drDangerSlavePageTo.setDrSlaveStatus(DrDangerSlaveEnum.WAIT.getDrState());
            drDangerSlavePageTo.setDrDangerStatus(DrDangerEnum.WAIT.getDrState());
        }
        drDangerSlavePageTo.setDrUserUuid(drUserUuid);
        Long count = drDangerHistoryMapper.countDrWaitByPage(drDangerSlavePageTo);
        DrPageBaseVo drPageBaseVo = new DrPageBaseVo(drDangerSlavePageTo.getDrPage(),
                drDangerSlavePageTo.getDrSize(), count);
        if (count == null || count == 0) {
            return DrResult.ok().data(drPageBaseVo);
        }
        RowBounds rowBounds = DrPageHelper.getRowBounds(drDangerSlavePageTo.getDrPage(),
                drDangerSlavePageTo.getDrSize());
        List<DrDangerWaitVo> drDangerHistoryVos = drDangerHistoryMapper.findDrWaitByPage(rowBounds, drDangerSlavePageTo);
        if (CollectionUtils.isEmpty(drDangerHistoryVos)) {
            return DrResult.ok().data(drPageBaseVo);
        }
        for (DrDangerWaitVo drDangerWaitVo : drDangerHistoryVos) {
            String drRectifyStr = drDangerWaitVo.getDrRectifyStr();
            if (StringUtils.isNotBlank(drRectifyStr)) {
                drDangerWaitVo.setDrRectify(DrGson.parseObject(drRectifyStr, DrDangerVo.class));
            }
        }
        drPageBaseVo.setDrData(drDangerHistoryVos);
        return DrResult.ok().data(drPageBaseVo);
    }

    /**
     * @return com.deep.deepenterpise.common.result.DrResult
     * @Auth xyz
     * @Desc //TODO 获取隐患清单列表
     * @Time 11:53 2024/6/24
     * @Param [drDangerPageTo]
     */
    @Override
    public DrResult postDrCheckDangerList(DrDangerPageTo drDangerPageTo) {
        Long count = drDangerHistoryMapper.countByPage(drDangerPageTo);
        DrPageBaseVo drPageBaseVo = new DrPageBaseVo(drDangerPageTo.getDrPage(), drDangerPageTo.getDrSize(), count);
        if (count != null && count > 0) {
            RowBounds rowBounds = DrPageHelper.getRowBounds(drDangerPageTo.getDrPage(), drDangerPageTo.getDrSize());
            List<DrDangerHistoryVo> drDangerHistoryVos = drDangerHistoryMapper.findByPage(rowBounds, drDangerPageTo);
            drPageBaseVo.setDrData(drDangerHistoryVos);
        }
        return DrResult.ok().data(drPageBaseVo);
    }

    /**
     * @return com.deep.deepenterpise.common.result.DrResult
     * @Auth xyz
     * @Desc //TODO 隐患子清单列表
     * @Time 13:22 2024/6/24
     * @Param [drDangerSlavePageTo]
     */
    @Override
    public DrResult postDrCheckDangerSlaveList(DrDangerSlaveTo drDangerSlaveTo) {
        List<DrDangerHistorySlaveVo> drDangerHistorySlaveVos = drDangerHistorySlaveMapper.findByDrDangerSlaveTo(drDangerSlaveTo);
        if (CollectionUtils.isEmpty(drDangerHistorySlaveVos)) {
            return DrResult.ok();
        }
        for (DrDangerHistorySlaveVo drDangerHistorySlaveVo : drDangerHistorySlaveVos) {
            String drRectifyStr = drDangerHistorySlaveVo.getDrRectifyStr();
            if (StringUtils.isNotBlank(drRectifyStr)) {
                drDangerHistorySlaveVo.setDrRectify(DrGson.parseObject(drRectifyStr, DrDangerVo.class));
            }
            String drDangerSlaveNum = drDangerHistorySlaveVo.getDrDangerSlaveNum();
            List<DrDangerItemVo> drDangerItems = drDangerHistoryItemMapper.findByDrDangerSlaveNum(drDangerSlaveNum);
            if (CollectionUtils.isEmpty(drDangerItems)) {
                continue;
            }

            String drPhoneStr = drDangerHistorySlaveVo.getDrPhotoStr();
            if (StringUtils.isNotBlank(drPhoneStr)) {
                drDangerHistorySlaveVo.setDrPhoto(DrGson.parseArray(drPhoneStr, String.class));
                drDangerHistorySlaveVo.setDrPhotoStr(null);
            }

            drDangerHistorySlaveVo.setDrDanger(drDangerItems);
        }

        return DrResult.ok().data(drDangerHistorySlaveVos);
    }

    /**
     * @return com.deep.deepenterpise.common.result.DrResult
     * @Auth xyz
     * @Desc //TODO 指派检查人
     * @Time 15:02 2024/6/24
     * @Param [drCheckPersonTo]
     */
    @Override
    @Transactional
    public DrResult drChooseCheckPerson(DrCheckPersonTo drCheckPersonTo) {
        String drDangerSlaveNum = drCheckPersonTo.getDrDangerSlaveNum();
        DrDangerHistorySlave dangerHistorySlave = drDangerHistorySlaveMapper.findByDrDangerSlaveNumAndDrStatus(drDangerSlaveNum,
                DrDangerSlaveEnum.WAIT_CHECK.getDrState());
        if (dangerHistorySlave == null) {
            return DrResult.error("隐患记录不存在或状态已改变");
        }
        String drPersonUuid = drCheckPersonTo.getDrPersonUuid();
        DrUserInfoBo drUserInfoBo = drSysUserMapper.findByDrUserUuidAndDrStatus(drPersonUuid, DrStateEnum.YES.getDrState());
        if (drUserInfoBo == null) {
            return DrResult.error("检查人不存在或状态异常");
        }
        dangerHistorySlave.setDrPerson(drPersonUuid);
        dangerHistorySlave.setDrStatus(DrDangerSlaveEnum.WAIT_RECHECK.getDrState());
        drDangerHistorySlaveMapper.update(dangerHistorySlave);
        return DrResult.ok("指派成功");
    }

    /**
     * @return com.deep.deepenterpise.common.result.DrResult
     * @Auth xyz
     * @Desc //TODO 隐患整改审核
     * @Time 15:27 2024/6/24
     * @Param [drDangerAuditTo]
     */
    @Override
    @Transactional
    public DrResult postDrDangerAudit(String drUserUuid, DrDangerAuditTo drDangerAuditTo) {
        DrUserInfoBo drUserInfoBo = drSysUserMapper.findByDrUserUuidAndDrStatus(drUserUuid, DrStateEnum.YES.getDrState());
        if (drUserInfoBo == null) {
            return DrResult.error("审核人不存在或状态异常");
        }
        String drDangerSlaveNum = drDangerAuditTo.getDrDangerSlaveNum();
        Integer drStatus = drDangerAuditTo.getDrStatus();
        DrDangerHistorySlave dangerHistorySlave = drDangerHistorySlaveMapper
                .findByDrDangerSlaveNumAndDrStatus(drDangerSlaveNum, DrDangerSlaveEnum.WAIT.getDrState());
        if (dangerHistorySlave == null) {
            return DrResult.error("隐患记录不存在或状态已改变");
        }

        long drNowTime = DrDateUtil.getCurrentSeconds();
        dangerHistorySlave.setDrReviewTime(drNowTime);
        dangerHistorySlave.setDrReviewer(drUserUuid);

        // 获取隐患记录
        DrDangerHistory dangerHistory = drDangerHistoryMapper.findByDrDangerNum(dangerHistorySlave.getDrDangerNum());
        if (dangerHistory == null) {
            return DrResult.error("隐患记录不存在");
        }

        if (DrStateEnum.YES.compare(drStatus)) {
            // 审核通过
            dangerHistorySlave.setDrStatus(DrDangerSlaveEnum.DONE.getDrState());

            // 更新隐患记录状态
            dangerHistory.setDrStatus(DrDangerEnum.DONE.getDrState());
        } else {
            // 审核不通过
            dangerHistorySlave.setDrStatus(DrDangerSlaveEnum.UNQUALIFIED.getDrState());

            String newDangerSlaveNum = DrOrderTypeEnum.DANGER_SLAVE.getDrCode() + drNowTime;

            // 新增新的隐患条目记录
            String drRectify = dangerHistorySlave.getDrRectify();
            DrDangerVo drDangerVo = DrGson.parseObject(drRectify, DrDangerVo.class);
            List<DrDangerItemVo> drDangerItems = drDangerVo.getDrDangerItems();
            for (DrDangerItemVo drDangerItemVo : drDangerItems) {
                DrDangerHistoryItem drDangerHistoryItem =
                        new DrDangerHistoryItem(newDangerSlaveNum, drDangerItemVo, drNowTime);
                drDangerHistoryItemMapper.insert(drDangerHistoryItem);
            }

            // 新增新的隐患子记录
            DrDangerHistorySlave newDangerHistorySlave = getDrDangerHistorySlave(newDangerSlaveNum,
                    dangerHistorySlave.getDrDangerNum(), drNowTime, drDangerVo.getDrDangerPhoto());
            drDangerHistorySlaveMapper.insert(newDangerHistorySlave);

            // 更新原有隐患记录状态
            dangerHistory.setDrStatus(DrDangerEnum.NO_START.getDrState());
        }
        dangerHistory.setDrUpdateTime(drNowTime);
        drDangerHistoryMapper.update(dangerHistory);
        drDangerHistorySlaveMapper.update(dangerHistorySlave);
        return DrResult.ok("审核成功");
    }

    /**
     * @return com.deep.deepenterpise.model.entity.DrDangerHistorySlave
     * @Auth xyz
     * @Desc //TODO 获取新的隐患子记录
     * @Time 17:18 2024/6/24
     * @Param [newDangerSlaveNum, dangerHistorySlave, drNowTime]
     */
    private DrDangerHistorySlave getDrDangerHistorySlave(String newDangerSlaveNum, String drDangerSlaveNum,
                                                         long drNowTime, List<String> drDangerPhoto) {
        DrDangerHistorySlave newDangerHistorySlave = new DrDangerHistorySlave();
        // 设置订单号
        newDangerHistorySlave.setDrDangerSlaveNum(newDangerSlaveNum);
        // 设置主订单号
        newDangerHistorySlave.setDrDangerNum(drDangerSlaveNum);
        // 设置状态
        newDangerHistorySlave.setDrStatus(DrDangerSlaveEnum.WAIT_CHECK.getDrState());
        // 设置照片
        newDangerHistorySlave.setDrPhoto(DrGson.toJSONString(drDangerPhoto));
        // 设置时间
        newDangerHistorySlave.setDrCreateTime(drNowTime);
        return newDangerHistorySlave;
    }

    /**
     * @return com.deep.deepenterpise.common.result.DrResult
     * @Auth xyz
     * @Desc //TODO 提交整改意见
     * @Time 09:57 2024/6/25
     * @Param [drUserUuid, drDangerPutTo]
     */
    @Override
    @Transactional
    public DrResult postDrDangerReviseSubmit(String drUserUuid, DrDangerPutTo drDangerPutTo) {
        DrUserInfoBo drUserInfoBo = drSysUserMapper.findByDrUserUuidAndDrStatus(drUserUuid, DrStateEnum.YES.getDrState());
        if (drUserInfoBo == null) {
            return DrResult.error("员工信息不存在或状态异常");
        }
        String drDangerSlaveNum = drDangerPutTo.getDrDangerSlaveNum();
        // 获取隐患子订单
        DrDangerHistorySlave dangerHistorySlave = drDangerHistorySlaveMapper
                .findByDrDangerSlaveNumAndDrStatus(drDangerSlaveNum, DrDangerSlaveEnum.WAIT_RECHECK.getDrState());
        if (dangerHistorySlave == null) {
            return DrResult.error("隐患子记录不存在或状态已改变");
        }
        String drDangerNum = dangerHistorySlave.getDrDangerNum();
        // 获取隐患记录
        DrDangerHistory dangerHistory = drDangerHistoryMapper.findByDrDangerNumAndDrStatus(drDangerNum,
                DrDangerEnum.NO_START.getDrState());
        if (dangerHistory == null) {
            return DrResult.error("隐患记录不存在或状态已改变");
        }

        // 获取所有隐患项
        List<DrUnitCheckItemVo> drCheckItemVos = drCheckItemMapper
                .findByDrCategoryAndDrStatus(drDangerPutTo.getDrType(), DrStateEnum.YES.getDrState());
        if (CollectionUtils.isEmpty(drCheckItemVos)) {
            return DrResult.error("安检项不存在或状态异常");
        }

        DrContentTo drContent = drDangerPutTo.getDrContent();
        List<DrItemTo> drItems = drContent.getDrItem();

        DrDangerVo drRectifyDangerVo = new DrDangerVo();
        List<DrDangerItemVo> drRectify = new ArrayList<>();
        List<Integer> drIds = new ArrayList<>();

        if (!CollectionUtils.isEmpty(drItems)) {
            for (DrItemTo drItem : drItems) {
                drRectify.add(new DrDangerItemVo(drItem.getDrItem(), drItem.getDrType(),
                        DrStateEnum.YES.getDrState()));
                drIds.add(drItem.getDrId());
            }
        }

        for (DrUnitCheckItemVo drCheckItemVo : drCheckItemVos) {
            if (drIds.contains(drCheckItemVo.getDrId())) {
                continue;
            }
            drRectify.add(new DrDangerItemVo(drCheckItemVo.getDrContent(), drCheckItemVo.getDrIsDangers(),
                    DrStateEnum.NO.getDrState()));
        }

        drRectifyDangerVo.setDrDangerItems(drRectify);
        drRectifyDangerVo.setDrDangerPhoto(drContent.getDrPhoto());

        dangerHistorySlave.setDrDangerSlaveSign(drDangerPutTo.getDrUrl());
        dangerHistorySlave.setDrRemark(drDangerPutTo.getDrRemark());
        dangerHistorySlave.setDrRectify(DrGson.toJSONString(drRectifyDangerVo));
        dangerHistorySlave.setDrStatus(DrDangerSlaveEnum.WAIT.getDrState());
        drDangerHistorySlaveMapper.update(dangerHistorySlave);

        dangerHistory.setDrStatus(DrDangerEnum.WAIT.getDrState());
        drDangerHistoryMapper.update(dangerHistory);
        return DrResult.ok("提交成功");
    }
}
